package com.kazusa.myservlet;

import java.io.*;

import jakarta.servlet.http.*;
import jakarta.servlet.annotation.*;
import jakarta.servlet.*;

/*实现servlet
1.创建普通类java
2.实现servlet规范
3.重写service方法，用来处理请求
4.设置注解，指定访问路径
*/
//@WebServlet("/hello")
@WebServlet(name = "LoginServlet",value = {"/hello","/hello1"})//路径中的/不要忘记写
public class HelloServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //req请求对象，resp响应对象
        //打印内容到控制台
        System.out.println("hello servlet");
        //通过流输出到浏览器
        resp.getWriter().write("hello servlet");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doGet(req, resp);
    }

    //service本质是调用get和post方法
}